Ext.define('Admin.view.overtimefile.OvertimeFileViewController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.overtimeFileViewController',

    closeWindow:function(bt){
        var win  = bt.up('window');
        if(win){
            win.close();
        }
    },

    openOvertimeFileWindow:function(view,recIndex,cellIndex,item,e,record){
        var win = Ext.create('widget.overtimeFileViewWindow',{
            title:'加班申请归档',
            items:{xtype:'overtimeFileForm'}
        });
        var form = Ext.getCmp('overtimeFileForm').getForm();
        form.loadRecord(record);
        form.findField('realOvertimeDate').setValue(record.data.overtimeDate);
    },

    overtimeFileFormSubmit:function(bt){
        var form = bt.up('form').getForm();
        var win = bt.up('window');

        form.submit({
            waitTitle: '请稍后...',
            waitMsg: '正在保存信息',
            url: 'overtime/file',
            method: 'post',
            params: {
                "_csrf": document.getElementsByTagName('meta')['_csrf'].content
            },
            success: function(form, action) {
                win.close();
                Ext.Msg.alert('提示', action.result.msg);
                Ext.getCmp('overtimeFileGrid').getStore().reload();
                if (Ext.getCmp('overtimeHistoryGrid')!=null) {
                    Ext.getCmp('overtimeHistoryGrid').getStore().reload();
                }
            },
            failure: function(form, action) {
                Ext.Msg.alert('提示', action.result.msg);
            }
        });
    }
    
})
